$(document).ready(function(){

// Highlight current page in menu

var path = window.location.pathname.split('/');
path = path[path.length-1];

if (path !== undefined) {
    $(".main_nav ul")
        .find("a[href='" + path + "']") // gets all links that match the href
        .parents('li')  // gets all list items that are ancestors of the link
        .children('a')  // walks down one level from all selected li's
        .addClass('current');
}

// user menu

        var user_menu = $("#user_menu .menu");
        var user_menu_btn = $("#user_menu .menu_btn");
        
        $(user_menu_btn).click(function(){
            if ($(user_menu).is(':hidden'))
                $(user_menu).stop(true, true).slideDown(200);   //Slide down menu
            else{
                $(user_menu).fadeOut();
            }
            return false;
        });

        $(user_menu).click(function(e) {
            e.stopPropagation();
        });
        
        
        $(document).click(function() {
            $(user_menu).fadeOut();
        });


//Main Tabs 
						$('.tabs').each(function(){
							var pane = $(this).closest(".tabbed_content").find("> .pane"); 
							$(this).tabs( pane, {effect: 'fade'});
						});


//Close button:
						$(".close_notification").click(
							function () {
								$(this).hide();
								$(this).parent().fadeTo('fast', 0, function () {
									$(this).slideUp('fast');
									});
						});

//Tooltip


							$('.enable_tip').tooltip({						 //will make a tooltip of all elements having a title property
											 opacity: 1.0,
											 effect: 'slide',
											 predelay: 200,
											 delay: 10,
											 position:	'top center',
											 layout:'<div><span class="arrow"></span></div>',
											 offset:[0, 0]
											 })
									.dynamic({bottom: { direction: 'down', bounce: true}   //made it dynamic so it will show on bottom if there isnt space on the top
						});



//Uniform
					  $("select, input:checkbox, input:radio, input:file").uniform();



// Carousel
					  $(".carousel_container").jCarouselLite({
						  btnNext: ".carousel_next",
						  btnPrev: ".carousel_prev",
						  visible:4
					  });

// Modal on click

						$("a.button[rel]").overlay({
										
										// disable this for modal dialog-type of overlays
										closeOnClick: true,
										mask: {
											color: '#323c49',
											loadSpeed: 200,
											opacity: 0.8
										}
						});


//Accordion
						$('.accordion').each(function(){
							var pane = $(this).find("> .pane"); 
							$(this).tabs( pane, {tabs: '.acc_header',  effect: 'slide'});
						});


//Toggle Control
    $("a.list_view_toggle").toggle(function(){
        $(this).addClass("grid");
        $("ul.guides_list").fadeOut("fast", function() {
            $(this).fadeIn("fast").addClass("grid_view");
        });
    }, function () {
        $(this).removeClass("grid");
        $("ul.guides_list").fadeOut("fast", function() {
            $(this).fadeIn("fast").removeClass("grid_view");
        });
    }); 
});


